﻿using AutoMapper;
using Enferno.Public.Web.Mappers.Resolvers;
using Enferno.Public.Web.Models;
using Enferno.StormApiClient.Shopping;

namespace Enferno.Public.Web.Mappers.BasketProfiles
{
    public class BasketModelToBasketProfile :
        BasketBaseModelToBasketProfile
            <BasketModel, BasketItemModel, PromotionModel, OnHandStatusModel, PriceModel, ProductFileModel>
    {
        
    }

    public class BasketBaseModelToBasketProfile<TBasketModel, TBasketItemModel, TPromotionModel, TOnHandStatusModel, TPriceModel, TProductFileModel> : Profile
        where TBasketModel : BasketBaseModel<TBasketItemModel, TPromotionModel, TOnHandStatusModel, TPriceModel, TProductFileModel>
        where TBasketItemModel : BasketItemBaseModel<TPriceModel>
        where TPromotionModel : PromotionBaseModel<TProductFileModel>
        where TOnHandStatusModel : OnHandStatusModel
        where TPriceModel : PriceModel
        where TProductFileModel : ProductFileModel
    {
        protected override void Configure()
        {
            Mapper.CreateMap<BasketModel, Basket>()
                .ForMember(basket => basket.SalesContactId,
                    basketModelMapConfig => basketModelMapConfig.Ignore())
                .ForMember(basket => basket.StatusId,
                    basketModelMapConfig => basketModelMapConfig.Ignore())
                .ForMember(basket => basket.CurrencyId,
                    basketModelMapConfig => basketModelMapConfig.Ignore())
                .ForMember(basket => basket.CurrencyCode,
                    basketModelMapConfig => basketModelMapConfig.Ignore())
                .ForMember(basket => basket.ReferId,
                    basketModelMapConfig => basketModelMapConfig.Ignore())
                .ForMember(basket => basket.ReferUrl,
                    basketModelMapConfig => basketModelMapConfig.Ignore())
                .ForMember(basket => basket.ValidTo,
                    basketModelMapConfig => basketModelMapConfig.Ignore())
                .ForMember(basket => basket.IsEditable,
                    basketModelMapConfig => basketModelMapConfig.Ignore())
                .ForMember(basket => basket.Info,
                    basketModelMapConfig => basketModelMapConfig.Ignore())
                .ForMember(basket => basket.Summary,
                    basketModelMapConfig => basketModelMapConfig.Ignore())
                .ForMember(basket => basket.ExtensionData,
                    basketModelMapConfig => basketModelMapConfig.Ignore())
                .ForMember(basket => basket.AppliedPromotions,
                    basketModelMapConfig => basketModelMapConfig.ResolveUsing<PromotionsResolver<TBasketModel, TBasketItemModel, TPromotionModel, TOnHandStatusModel, TPriceModel, TProductFileModel>>())
                .ForMember(basket => basket.Items,
                    basketModelMapConfig => basketModelMapConfig.ResolveUsing<BasketItemsResolver<TBasketModel, TBasketItemModel, TPromotionModel, TOnHandStatusModel, TPriceModel, TProductFileModel>>());
        }

        public override string ProfileName
        {
            get { return GetType().Name; }
        }
    }


}
